package com.test.activemq.simple;

import javax.jms.JMSException;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;

public class Receiver {

	// ActiveMQConnectionFactory factory = new
	// ActiveMQConnectionFactory("tcp://192.168.180.129:61616");
	public static void main(String[] args) throws JMSException {

		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		JmsTemplate jmsTemplate = (JmsTemplate) context.getBean("jmsTemplate");
		
		String msg = (String)jmsTemplate.receiveAndConvert();
		
		System.out.println(msg);

	}
	// public static void main(String[] args) throws JMSException {
	//
	// ActiveMQConnectionFactory factory = new
	// ActiveMQConnectionFactory("tcp://localhost:61616");
	//
	// Connection connection = factory.createConnection();
	// connection.start();
	//
	// Session session = connection.createSession(true,
	// Session.AUTO_ACKNOWLEDGE);
	//
	// Queue queue = session.createQueue("20190319");
	//
	// MessageConsumer consumer = session.createConsumer(queue);
	// int i = 0;
	// while (i++ < 3) {
	// System.out.println("接收消息。。。");
	// TextMessage msg = (TextMessage) consumer.receive();
	//
	// System.out.println(msg.getBooleanProperty("是否真诚"));
	//
	// System.out.println("接收到消息:" + msg.getText());
	// }
	//
	// session.commit();
	// session.close();
	// connection.close();
	//
	// }
}
